Skip to content

[DowngradePhp81] Skip PHP_VERSION_ID guarded hash() calls in DowngradeHashAlgorithmXxHashRector - #394

Merged
TomasVotruba merged 2 commits into
mainfrom
fix-php-version-id-guard-xxhash
Aug 30, 2026
Merged

[DowngradePhp81] Skip PHP_VERSION_ID guarded hash() calls in DowngradeHashAlgorithmXxHashRector#394
TomasVotruba merged 2 commits into
mainfrom
fix-php-version-id-guard-xxhash

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

skip_check_phpversion_ternary fixture regressed: hash('xxh128') inside a PHP_VERSION_ID >= 80100 ? guard was rewritten to md5 instead of being skipped.

Two skip paths both stopped catching PHP_VERSION_ID guards:

  • PHP_VERSION_CONDITIONED attribute is only set upstream for version_compare() conditions, not PHP_VERSION_ID binary ops.
  • The scope-based check expected an IntegerRangeType with min 80100, but the scope now resolves to a concrete ConstantIntegerType, so that branch never triggers.

This subscribes the rule to Ternary/If_, and when their condition is a PHP_VERSION_ID comparison, marks the inner hash() calls with PHP_VERSION_CONDITIONED so they are skipped the same way version_compare() guarded calls already are. The dead scope-based check is removed.

…eHashAlgorithmXxHashRector

Mark hash() calls inside a PHP_VERSION_ID guarded ternary/if as version conditioned,
so they are skipped like version_compare() guarded calls. Drops the dead scope-based
check, which no longer resolves to an IntegerRangeType.

Claude-Session: https://claude.ai/code/session_01UCwZigZyZFXK9SNVFLQsRi
@TomasVotruba
TomasVotruba force-pushed the fix-php-version-id-guard-xxhash branch from f7c53af to 198e0e3 Compare August 30, 2026 22:30
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 30, 2026 22:30
@TomasVotruba
TomasVotruba merged commit 70b30bb into main Aug 30, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the fix-php-version-id-guard-xxhash branch August 30, 2026 22:31
ondrejmirtes pushed a commit to phpstan/phpstan that referenced this pull request Sep 2, 2026
The `Rector downgrade PHP tests` job has been red on every phpstan-src
pull request with a single failure: DowngradeHashAlgorithmXxHashRector's
skip_check_phpversion_ternary fixture, where hash('xxh128', $value)
inside a PHP_VERSION_ID >= 80100 guard gets rewritten to md5 instead of
being skipped.

That was fixed upstream in rectorphp/rector-downgrade-php#394, merged
2026-08-30. The rule no longer depends on the guard resolving to an
IntegerRangeType and marks PHP_VERSION_ID guarded calls the way
version_compare() guarded ones already were.

The pinned e77a75a0 is 13 commits behind and predates that. Bumping the
pin and regenerating rector-downgrade-php-composer.lock, which is
needed because composer.json moved in between (PHPUnit 13, and
rector/type-perfect replaced by tomasvotruba/type-coverage) and both
downgrade jobs read that one lock.

Verified by replaying both jobs with the current 2.2.x phar
(2.2.x-dev@7cdfeaa) copied in the way the jobs do it:

  vendor/bin/phpunit               647 tests, 2 skipped, no failures
                                   (635 tests, 1 failure at the old pin)
  analyse -c ../rector-downgrade-php.neon   no errors, and the existing
                                   baseline entry still matches

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants